<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>粘性定位</title>
    <style>
        /* 粘性定位特点：
        1.以浏览器可视化窗口为参照点移动元素
        2.粘性定位占有原先的位置
        3.必须添加top,left,right,bottom其中一个才有效 */
        body {
            height: 3500px;
        }
        .nav {
            position: sticky;
            top: 0;
            width: 800px;
            height: 50px;
            background-color: pink;
            margin: 100px auto;
        }
    </style>
</head>
<body>
    <div class="nav"></div>
</body>
</html>